﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using XCMSData;
using XCode.DataAccessLayer;
public partial class LoginIn : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["Act"] == "Logout")
        {
            XCMSData.User.Current = null;
            Session.Abandon();
            Response.Redirect("Login.aspx");
        }
    }
    protected void btn_Ok_Click(object sender, EventArgs e)
    {
        try
        {
            User LoginUser = XCMSData.User.Login(txt_UserName.Text.Trim(), txt_PassWord.Text.Trim(), true);
            if (LoginUser != null)
            {
                XCMSData.User.LoginUpdate(LoginUser, Request.UserHostAddress);
                XCMSData.User.Current = LoginUser;
                Response.Redirect("Admin/index.aspx");
            }       
        }
        catch (Exception ex)
        {
            lb_ErrorText.Text = ex.Message;
        }

    }
}
